<?php

include_once("core/controller.php");
include_once("core/libs/file.php");
include_once("core/versionHandler.php");
/**
 * This Controller is used to save the release of the site
 * @copyright inovia
 * @package oolime_manager 
 *
 */
class ExportSite extends Controller {
   
   protected function isLegitimate(){
      return true;
   }



   /**
    * Function doing the actions of the Controller
    */
  protected function actions(){
  
    $version = new Version("");
    $root    = new DOMElement('MyVersion');
    $this->response->doc->appendChild($root);
    $t       = $version->exportXML($this->response->doc);            
    $root->appendChild($t);
    $this->response->add($root);
    $nameExport="resources/packages/framework/version_".$version->getNumber()."_".$version->getSurname();
   
    //saves directories
    $tab=$version->getcontainsD();
    if(count($tab)){
      foreach($tab as $pathDir){
        dircopy($pathDir,$nameExport."/".$pathDir, false);
      }
    }
   
    //saves files
    $tab=$version->getcontainsF();
    if(count($tab)){
      foreach($tab as $pathF){
        fcopy($pathF,$nameExport."/".$pathF, false);
      }
    }
     
     //recuperer des tables...
     //$this->database->exportFilterTables(Array("dispatcher"),$nameExport."/exportTables/export.sql.gz","rel_path LIKE 'Engine%'");
      
     //recuperer des fichiers
     //copy("http://www.google.fr","here");
      
     $this->response->setXSLT("views/manager/saveVersion.xsl");

   }


   /**
    * Function doing default actions of the Controller
    */
   protected function defaultActions(){}

}



?>
